#include<iostream>
#include<string>
using namespace std;
string tmp,s;
string dict[]={"1111110","1011011","0110000","1011111","1101101","1110000","1111001","1111111","0110011","1111011"};
int k=0;
bool find()
{
    for(int i=0;i<13;i++)
        if(s==dict[i])return true;
    return false;
}
void dfs(int u)//枚举每一种情况
{
    if(u==s.size())
    {
        if(find())k++;
        return;
    }
    if(s[u]=='1')dfs(u+1);
    else
    {
        //首先将这个地方改成1试一试
        s[u]='1';
        dfs(u+1);
        //恢复现场
        s[u]='0';
        dfs(u+1);
    }
}

int main()
{
    for(int i=0;i<18;i++)
    {
        cin>>s;
        tmp=s;//备份
        dfs(0);
    }
    cout<<k<<endl;
    return 0;
}